package com.hhj.sharding.sphere.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hhj.sharding.sphere.demo.model.Table2ParamVO;
import com.hhj.sharding.sphere.demo.model.TableParamVO;
import com.hhj.sharding.sphere.demo.model.entity.SingleTable;
import com.hhj.sharding.sphere.demo.model.entity.SingleTable2;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author HHJ
 * @since 2024-05-22
 */
public interface SingleTable2Mapper extends BaseMapper<SingleTable2> {

    @Select("<script>" +

            " SELECT RE.* FROM tb_single_table2 RE " + " WHERE RE.id > 0 " +

            " <if test=\"req.id != null \"> " + " AND RE.id = #{req.id}" + " </if> " +

            " <if test=\"req.code != null \"> " + " AND RE.code = #{req.code}" + " </if> " +

            " <if test=\"req.name != null \"> " + " AND RE.name = #{name}" + " </if> " +

            " <if test=\"req.title != null \"> " + " AND RE.title = #{req.title}" + " </if> " +

            " ORDER BY RE.id DESC" +

            "</script>")
    List<SingleTable2> findList(@Param("page") Page page, @Param("req") Table2ParamVO req);

}
